<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 用户信息</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="${ctx!}/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx!}/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx!}/admin/css/animate.css" rel="stylesheet">
    <link href="${ctx!}/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="${ctx!}/admin/css/bootstrap-datetimepicker.css" rel="stylesheet">
    <link href="${ctx!}/admin/css/fileinput.css" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>用户信息</h5>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="frm" method="post" action="${ctx!}/admin/linkman/save" enctype="multipart/form-data">
                        	<input type="hidden" id="id" name="id" value="${(linkman.id)!}">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">姓名：</label>
                                <div class="col-sm-8">
                                    <input id="userName" name="userName" class="form-control" type="text" value="${(linkman.userName)!}" <#if linkman?exists> readonly="readonly" </#if>>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">联系电话：</label>
                                <div class="col-sm-8">
                                    <input id="mobile" name="mobile" class="form-control" type="text" value="${(linkman.mobile)!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">QQ/微信：</label>
                                <div class="col-sm-8">
                                    <input id="wechat" name="wechat" class="form-control" type="text" value="${(linkman.wechat)!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">生日：</label>
                                <div class="col-sm-8">
                                    <input id="birthday" name="birthday" class="form-control form_datetime" type="text" value="${(linkman.birthday)!}" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">性别：</label>
                                <div class="col-sm-8">
                                	<select name="sex" class="form-control">
                                		<option value="0"   <#if linkman.sex == 0> selected="selected" </#if> >女</option>
                                		<option value="1"   <#if linkman.sex == 1> selected="selected" </#if> >男</option>
                                	</select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">职业：</label>
                                <div class="col-sm-8">
                                    <input id="career" name="career" class="form-control" type="text" value="${linkman.career!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">头像：</label>
                                <div class="col-sm-8">
                                    <input id="file" name="file" class="form-control" type="file" data-overwrite-initial="false" data-min-file-count="1">
                                    <input id="photo" name="photo" type="hidden" <#if linkman.photo??> value="${linkman.photo!}" <#elseif !linkman.photo??>value="1234567890123.jpg"</#if>/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">省份：</label>
                                <div class="col-sm-8">
                                    <select id="level1" name="level1" class="form-control"></select>
                                </div>
                                <input id="province" name="province" type="hidden" value="${(linkman.province)!}"/>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">城市：</label>
                                <div class="col-sm-8">
                                    <select id="level2" name="level2" class="form-control"></select>
                                </div>
                                <input id="city" name="city" type="hidden" value="${(linkman.city)!}"/>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">详细地址：</label>
                                <div class="col-sm-8">
                                    <input id="address" name="address" class="form-control" type="text" value="${(linkman.address)!}">
                                </div>
                            </div>                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">描述：</label>
                                <div class="col-sm-8">
                                    <input id="description" name="description" class="form-control" value="${(linkman.description)!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>


    <!-- 全局js -->
    <script src="${ctx!}/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctx!}/admin/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="${ctx!}/admin/js/content.js?v=1.0.0"></script>

    <!-- jQuery Validation plugin javascript-->
    <script src="${ctx!}/admin/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${ctx!}/admin/js/plugins/validate/messages_zh.min.js"></script>
    <script src="${ctx!}/admin/js/plugins/layer/layer.min.js"></script>
    <script src="${ctx!}/admin/js/plugins/layer/laydate/laydate.js"></script>
    <script src="${ctx!}/admin/js/bootstrap-datetimepicker.js"></script>
    <script src="${ctx!}/admin/js/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="${ctx!}/admin/js/init-area.js"></script>
    <script src="${ctx!}/admin/js/fileinput.js"></script>
    <script type="text/javascript">
    $("#birthday").datetimepicker({
        format: 'yyyy-mm-dd',
        minView:'month',
        language: 'zh-CN',
        autoclose:true,
        todayBtn: true
    });
    
     $("#file").fileinput({
        uploadUrl: '${ctx!}/admin/uploadfile/photo', 
        overwriteInitial: false,
        maxFileSize: 1000,
        maxFilesNum: 10,
        language : 'zh',  
        minFileCount: 1,  
    	maxFileCount: 1,
    	uploadAsync: true,
    	showPreview: false,
        allowedFileExtensions : ['jpg', 'png','gif']
	}).on('filebatchuploadsuccess', function(event, data, previewId, index) {
    	var response = data.response;
    	console.info(response.msg);
    	$("#photo").val(response.msg);
	});
	
    $(document).ready(function () {
	    $("#frm").validate({
    	    rules: {
    	    	userName: {
    	        required: true,
    	        minlength: 2
    	      },
    	      	mobile: {
    	        required: true,
    	        minlength: 7,
    	    	maxlength: 11
    	      },
    	      	province: {
    	      	required: true	
    	      },
    	      	city: {
    	      	required: true	
    	      }
    	    },
    	    messages: {},
    	    submitHandler:function(form){
    	    	$.ajax({
   	    		   type: "POST",
   	    		   dataType: "json",
   	    		   url: "${ctx!}/admin/linkman/save",
   	    		   data: $(form).serialize(),
   	    		   success: function(ret){
   	    			   if(ret.isOk){
		   	    			layer.msg("操作成功", {time: 2000},function(){
		   						var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		   						parent.layer.close(index); 
		   					});
   	    		   	    }else{
   	    		   	  		layer.msg(ret.msg, {time: 2000});
   	    		   	    }
   	    		   }
   	    		});
            } 
    	});
    });
    
    _init_area();
    
    $("#level1").change(function(){
    	var province = $(this).val();
    	if(province != null && province != ""){
    		$("#province").val(province);
    	}
    });
    
    $("#level2").change(function(){
    	var city = $(this).val();
    	if(city != null && city != ""){
    		$("#city").val(city);
    	}
    });

    </script>
    
</body>

</html>
